// 旅游攻略相关接口
import request from '@/util/request.js'

// 获取轮播图
export const getBanners = () =>
  request.get('travel/banners')

// 获取热门攻略
export const getHotGuides = (params) =>
  request.get('travel/guides/hot', { params })

// 获取攻略详情
export const getGuideDetail = (id) =>
  request.get(`travel/guides/${id}`)

// 获取热门目的地
export const getHotDestinations = (params) =>
  request.get('travel/destinations/hot', { params })

// 获取目的地详情
export const getDestinationDetail = (id) =>
  request.get(`travel/destinations/${id}`)

// 获取精选游记
export const getFeaturedNotes = (params) =>
  request.get('travel/notes/featured', { params })

// 获取游记详情
export const getNoteDetail = (id) =>
  request.get(`travel/notes/${id}`)

// 获取攻略分类
export const getCategories = () =>
  request.get('travel/categories')

// 获取问答列表
export const getQAList = (params) =>
  request.get('travel/qa', { params })

// 搜索攻略
export const searchGuides = (keyword, params) =>
  request.get('travel/search', { params: { keyword, ...params } })

// 获取攻略列表
export const getGuideList = (params) =>
  request.get('travel/guides', { params })

// 获取攻略分类列表
export const getGuideCategories = () =>
  request.get('travel/guide/categories')

// 点赞攻略
export const likeGuide = (id) =>
  request.post(`travel/guides/${id}/like`)

// 添加评论
export const addComment = (data) =>
  request.post('travel/guide/comment', data)

// 获取景点详情
export const getAttractionDetail = (id) =>
  request.get(`travel/attractions/${id}`)

// 获取景点列表
export const getAttractionList = (params) =>
  request.get('travel/attractions', { params })

// 创建攻略
export const createGuide = (data) =>
  request.post('travel/guides', data)

// 上传图片
export const uploadImage = (file) => {
  const formData = new FormData()
  formData.append('file', file)
  return request.post('travel/upload/image', formData, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

// 获取社区动态列表
export const getCommunityPosts = (params) =>
  request.get('travel/community/posts', { params })

// 获取社区动态详情
export const getCommunityDetail = (id) =>
  request.get(`travel/community/posts/${id}`)

// 创建社区动态
export const createCommunityPost = (data) =>
  request.post('travel/community/posts', data)

// 点赞动态
export const likePost = (id) =>
  request.post(`travel/community/posts/${id}/like`)

// 添加动态评论
export const addPostComment = (data) =>
  request.post('travel/community/comment', data)
